#include "../source/server.hpp"
void MessageCallBack(const PtrConn &pcn, Buffer *buf)
{
    DBG_LOG("%s", buf->ReadPosition());
    buf->MoveReadOffset(buf->ReadAbleSize());

    std::string str = "hello world";
    pcn->Send((char *)str.c_str(), str.size());
}

void ServerCloseCallBack(const PtrConn &pcn)
{
    DBG_LOG("cloase a connection");
}

void ConnectedCallBack(const PtrConn &pcn)
{
    DBG_LOG("create a new Connected %p", pcn.get());
}


int main()
{
    TcpServer svr(8080);
    svr.SetPoolCapacity(2);
    svr.EnableInactiveRelease(5);
    svr.SetMessageCallback(MessageCallBack);
    svr.SetConnectedCallback(ConnectedCallBack);
    svr.SetClosedCallback(ServerCloseCallBack);
    svr.Start();

    return 0;
}